using System;
using System.Collections.Generic;
using System.Threading;
using System.Workflow.Runtime;

namespace DP.Sharepoint.Workflow.Tests.ForTesting
{
    [Serializable]
    public sealed class WorkflowInstanceWrapper
    {
        private Exception _exception;
        private Dictionary<String, Object> _outputParameters = new Dictionary<string, object>();
        private String _reasonSuspended = String.Empty;
        private ManualResetEvent _waitHandle = new ManualResetEvent(false);
        private WorkflowInstance _workflowInstance;

        public WorkflowInstanceWrapper(WorkflowInstance instance)
        {
            if (instance == null)
                throw new NullReferenceException("A non Null value is required for parameter [WorkflowInstance]");
            _workflowInstance = instance;
        }

        public WorkflowInstance WorkflowInstance
        {
            get { return _workflowInstance; }
            set { _workflowInstance = value; }
        }

        public Guid Id
        {
            get { return (_workflowInstance == null) ? Guid.Empty : _workflowInstance.InstanceId; }
        }

        public Dictionary<String, Object> OutputParameters
        {
            get { return _outputParameters; }
            set { _outputParameters = value; }
        }

        public Exception Exception
        {
            get { return _exception; }
            set { _exception = value; }
        }

        public String ReasonSuspended
        {
            get { return _reasonSuspended; }
            set { _reasonSuspended = value; }
        }

        public ManualResetEvent WaitHandle
        {
            get { return _waitHandle; }
            set { _waitHandle = value; }
        }

        public void StopWaiting()
        {
            _waitHandle.Set();
        }

    }
}